package com.itsitio.registeradmin.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "empresas")
public class Company {
//public class Company extends MappedEntity{

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "idx")
	private Integer id;
	
	//Empresa Nombre = Razon Social (SA, SRL)
	@Column(name = "nombre", length = 150)
	private String firmName;

	//taxId = cuit de Empresa
	@Column(name = "cuit", length = 50)
	private String taxId;
	
	@ManyToOne(cascade = CascadeType.MERGE)
	@JoinColumn(name="tipo")
	CompanyType companyType;

	//
	//TODO agregar aqui el pais de la empresa
	//
	
	//
	//TODO agregar aqui el PORTAL de la empresa
	//
	
	//
	//TODO agregar aqui la VISION de la empresa
	//

	//
	//TODO agregar aqui la MISION de la empresa
	//

	//e-mail - correo electronico
	@Column(name = "email", length = 100)
	private String email;
	
	//web
	@Column(name = "website", length = 150)
	private String website;
	
	//
	//TODO agregar aqui campo PUBLICADO de la empresa
	//
		
	//Empresa Fantasia = Nombre Comercial = Nombre en el mercado para consumidores
	@Column(name = "fantasia", length = 50)
	private String tradeName;
	
	// Razones Sociales de la Empresa
	//@OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL, mappedBy="country")
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER, mappedBy="company")
	private List<CompanyFirmName> companyFirmNames;

	
	
	
	
	/*, 
	@JoinTable(name = "xxxempresas_relacion_sucursales")
			joinColumns = { @JoinColumn(name = "idxempresa") }, 
			inverseJoinColumns = { @JoinColumn(name = "idxsucursal") })	
			*/
	/*@OneToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "empresas_relacion_sucursales",
			joinColumns = {@JoinColumn(name="idxempresa", unique = true)}, 
			inverseJoinColumns = {@JoinColumn(name="idxsucursal")})*/
	@OneToMany(mappedBy="company")
	private List<Branch> branches;	

	public Integer getId() {
		return id;
	}


	public void setId(Integer id) {
		this.id = id;
	}


	public String getFirmName() {
		return firmName;
	}


	public void setFirmName(String firmName) {
		this.firmName = firmName;
	}


	public String getTaxId() {
		return taxId;
	}


	public void setTaxId(String taxId) {
		this.taxId = taxId;
	}


	public CompanyType getCompanyType() {
		return companyType;
	}


	public void setCompanyType(CompanyType companyType) {
		this.companyType = companyType;
	}


	public String getEmail() {
		return email;
	}


	public void setEmail(String email) {
		this.email = email;
	}


	public String getWebsite() {
		return website;
	}


	public void setWebsite(String website) {
		this.website = website;
	}


	public String getTradeName() {
		return tradeName;
	}


	public void setTradeName(String tradeName) {
		this.tradeName = tradeName;
	}


	public List<CompanyFirmName> getCompanyFirmNames() {
		return companyFirmNames;
	}
	

	public void setCompanyFirmNames(List<CompanyFirmName> companyFirmNames) {
		this.companyFirmNames = companyFirmNames;
	}
	

	public List<Branch> getBranches() {
		return branches;
	}
	

	public void setBranches(List<Branch> branches) {
		this.branches = branches;
	}
	

	public Company(String firmName, String taxId, CompanyFirmName companyFirmNames) {
		this.firmName = firmName;
		this.taxId = taxId;		
	}


	public Company() {
		super();
		// TODO Auto-generated constructor stub
	}

	public void addCompanyFirm(CompanyFirmName companyFirm) {
		this.getCompanyFirmNames().add(companyFirm);
	}
	
	public void removeCompanyFirm(CompanyFirmName companyFirm) {
		this.getCompanyFirmNames().remove(companyFirm);
	}
	
}
